﻿
Partial Class store_UCEBook
    Inherits System.Web.UI.UserControl

    Public Sub Display(p As CProduct, list As CProductList)
        If Me.Parent.Controls.Count Mod 2 = 1 Then row.Attributes.Add("class", "alt_row")

        litNum.Text = 1 + list.IndexOf(p)

        With lnkSermon
            .Text = p.ProductName
            If p.IsSet Then .Text = p.ProductNameAndContents.Replace("1 Manual, ", "")
            .ToolTip = String.Concat("View the Transcript(s)", vbCrLf, vbCrLf, p.ProductNameAndContents, vbCrLf, vbCrLf, CUtilities.Truncate(p.ProductDescriptionOrParent, 500))
            .NavigateUrl = CSitemap.Decide(p)
        End With

        With lnkMobi
            If p.Files.HasMobi Then
                .Text = CUtilities.FileSize(p.Files.FirstMobi.FileSize)
                .NavigateUrl = CConfig.DropboxUrl(p.Files.FirstMobi.FileName)
            Else
                .Visible = False
            End If
        End With

        With lnkKindle
            .NavigateUrl = CSitemap.External_Amazon(p.ProductAmazonIdOrParent)
            .Visible = Not String.IsNullOrEmpty(p.ProductAmazonIdOrParent)
            .Text = CUtilities.Truncate(p.ProductAmazonIdOrParent, 10)
        End With

        With lnkEpub
            If p.Files.HasEpub Then
                .Text = CUtilities.FileSize(p.Files.FirstEpub.FileSize)
                .NavigateUrl = CConfig.DropboxUrl(p.Files.FirstEpub.FileName)
            Else
                .Visible = False
            End If
        End With

        With lnkPg1
            If p.HasTranscript Then
                .NavigateUrl = CSitemap.TranscriptWithPaging(p)
            ElseIf p.Children.HavingTranscripts.Count > 0 Then
                .NavigateUrl = CSitemap.TranscriptWithPaging(p)
            Else
                .NavigateUrl = lnkSermon.NavigateUrl 'businessmens
            End If
        End With

        With lnkHtml
            If p.HasTranscript OrElse p.Children.HavingTranscripts.Count > 0 Then
                .NavigateUrl = CConfig.WebsiteUrl_TranscriptAsHtm(p.ProductId)
            ElseIf p.Files.HasHtm AndAlso p.ProductTypeId_ = EProductType.Manual Then
                .NavigateUrl = CConfig.DropboxUrl(p.Files.FirstHtm.FileName)
            Else
                .Visible = False
            End If
        End With
    End Sub

End Class
